
import librosa
import os
from tqdm import tqdm

raw_path = '../dataset/test_offline/task3_result'
target_path = '../dataset/test_offline/task3_estimate'
try:
    os.mkdir(target_path)
except:
    print('  Target Path : (' + target_path + ') Already Exists.')

raw_list = os.listdir(raw_path)

for audio_idx in tqdm(range(len(raw_list)), ncols=70):
    # print(audio)
    audio = raw_list[audio_idx]

    audio_path = os.path.join(raw_path, audio)
    target_audio_path = os.path.join(target_path, audio)

    y, sr = librosa.load(audio_path, sr=8000)
    y_44100 = librosa.resample(y, sr, 44100)

    librosa.output.write_wav(target_audio_path, y_44100, 44100)